package com.awesumgames.awesum;

import java.util.concurrent.LinkedBlockingDeque;

//TODO: make this an interface and get rid of the noChildren constructor, maybe RunnableTree for things with children?
public abstract class RunnableTree implements Runnable {
	public LinkedBlockingDeque<Runnable> children = null;

	public RunnableTree() {
		children = new LinkedBlockingDeque<Runnable>();
	}
	public RunnableTree(boolean noChildren) {
		if (!noChildren)
			children = null;//new LinkedBlockingDeque<Runnable>();
	}
	
	public void load() {
		if (children != null)
			for (Runnable r : children)
				r.load();
	}
	public void draw() {
		if (children != null)
			for (Runnable r : children)
				r.draw();
	}
	public void step() {
		if (children != null)
			for (Runnable r : children)
				r.step();
	}
	
	public void empty() {
		//TODO: maybe implement unloads and call em all before deleting
		children.clear();
	}
}
